

1 CLS : Z$ = "": PRINT "INPUT ALL ENTRIES IN CAPITAL LETTERS"
5 INPUT "INPUT UNIT ID >> ", UNITNUM           'GET UNIT NUMBER
30 REM OPEN COM PORT SET FOR COM2 EDIT TO COM1 IF NEED
40 OPEN "COM2:1200,N,8,1,ASC" FOR RANDOM AS #2
50 PRINT : INPUT "ENTER STRING (HIT Q TO EXIT) >> ", I$ 'GET OUTPUT STRING FROM USER
65 IF I$ = "" THEN GOTO 50                      'IF BLANK INPUT THEN GO BACK
70 IF I$ = "Q" THEN GOTO 200                    'IF "Q" INPUT THEN QUIT
80 GOSUB 10000                                  'CONVERT STRING TO DASNET FORMAT
90 GOSUB 20000                                  'OUT DASNET STRING TO COM 2
120 PRINT "DASNET FORMATTED CMD >> "; O$        'OUTPUT FORMATTED CMD TO USER
124 PRINT : PRINT ">>>> PRESS CTRL-C IF NO RESPONSE FROM PUMP <<<<"
125 LINE INPUT #2, Z$                           'GET RESPONSE FROM PUMP 'CR' ENDS STRING
127 PRINT "DASNET RESPONSE >> "; Z$             'PRINT RESPONSE
128 Z$ = ""                                     'CLEAR BUFFER
130 GOTO 50                                     'GO BACK
200 CLOSE #2                                    'CLOSE COM2
210 SYSTEM                                      'END PROGRAM AND EXIT TO DOS

10000 REM this SUBROUTINE will convert a string (I$) into a string (O$)
10005 REM in DASNET protocol
10015 REM UNITNUM=UNIT NUMBER OF PUMP
10020 REM AFTER THE STRING IS SENT TO PUMP A CR IS REQUIRED TO TERMINATE MESSAGE
10030 REM VAR USED O$,I$,IL,Y$,LI,SUM,CSUM,UNITNUM
10100 O$ = CHR$(ASC("0") + UNITNUM)       'PUT UNIT ID FIRST IN OUTPUT STRING
10110 IL = LEN(I$)                        'GET LENGTH OF INPUT STRING
10115 REM IF INPUT IS JUST "R" ADD SPACE AND JMP BY # CHAR
10120 IF I$ = "R" THEN I$ = I$ + " ": GOTO 10180
10130 O$ = O$ + "R"                       'ADD "R" TO OUTPUT STRING
10140 Y$ = HEX$(IL)                       'GET # OF CHAR IN INPUT STRING IN HEX
10150 IF IL < 16 THEN Y$ = "00" + Y$      'PAD OUT # CHAR IN STRING IF NEED
10160 IF IL >= 16 THEN Y$ = "0" + Y$      'IF MORE THAN 16 THEN ONLY ONE PAD
10170 O$ = O$ + Y$                        'ADD # CHAR TO OUTPUT STRING
10180 O$ = O$ + I$                        'ADD INPUT STRING TO OUTPUT STRING
10190 IL = LEN(O$): SUM = 0               'GET NEW LENGTH AND CLEAR SUM OUT
10200 FOR LI = 1 TO IL                    'TO ADD ALL ASCII FOR SUM
10210 SUM = SUM + ASC(MID$(O$, LI, 1))    'GET THE ASCII # OF (LI) ASCII CHAR
10220 NEXT LI
10230 REM THIS FINDS THE CHECKSUM
10235 REM THE # IS FIRST SUBTRACTED FROM 256
10236 REM THEN ANDED WITH 255 TO AND OFF EXTRA BITS
10240 CSUM = (256 - SUM) AND 255           'GET CHECK SUM
10245 IF CSUM < 16 THEN O$ = O$ + "0"     'PAD OUT CSUM IF NEED
10250 O$ = O$ + HEX$(CSUM)                 'PUT AT END OF OUTPUT STRING
10270 RETURN                               'DONE RETURN
                                                  
20000 REM THIS SUBROUTINE SENDS O$ TO THE COM PORT
20010 PRINT #2, 'CR';      'SEND CR TO COM PORT
20020 PRINT #2, O$;        'SEND O$ TO COM PORT
20030 PRINT #2, 'CR';      'SEND CR TO COM PORT
20040 RETURN               'DONE

